package com.zch.poly.polyparameter;

public class Test {
    public static void main(String[] args) {
        Worker tom = new Worker("Tom", 2500);
        Manager jack = new Manager("Jack", 5000, 200000);
        Test test = new Test();
        test.showEmpAnnual(tom);
        test.showEmpAnnual(jack);

        test.testWorker(tom);
        test.testWorker(jack);
    }

    public void showEmpAnnual(Employee e) {
        System.out.println(e.getAnnual()); //动态绑定机制
    }

    public void testWorker(Employee e) {
        if (e instanceof Manager) {
            ((Manager) e).manage();
        } else if (e instanceof Worker) {
            ((Worker) e).work();
        } else {
            System.out.println("不做处理....");
        }
    }
}
